<template>
  <div>
    <div class="header">
      <div class="header-media">
        <van-image
          width="100"
          height="100"
          lazy-load
          src="https://img01.yzcdn.cn/vant/cat.jpeg"
        />
      </div>
      <div class="header-title">
        <div class="header-title-name">{{ username }}</div>
        <div>{{ userInfo.college }}</div>
        <div>{{ userInfo.class }}</div>
      </div>
      <div class="header-setting">
        <van-icon name="setting-o" />
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      username: localStorage.getItem('Username'),
      userInfo: {
        sex: 0,
        school: '',
        college: '',
        class: '',
        idNumber: '',
        phoneNumber: ''
      }
    }
  },
  created() {
    this.getUserInfo()
  },
  methods: {
    getUserInfo() {
      this.$api.serveapi
        .getUserInfo(this.username)
        .then(res => {
          this.userInfo = res.data.result[0]
        })
        .catch(err => {})
    }
  }
}
</script>
<style lang="scss" scoped>
.header {
  box-sizing: border-box;
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  height: 240px;
  color: #fff;
  padding: 0 15px;
  background-color: #1b89fa;
  .header-media {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 10px;
  }
  .header-title {
    font-size: 15px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    .header-title-name {
      font-size: 18px;
      font-weight: 800;
      margin-bottom: 5px;
    }
  }
  .header-setting {
    position: absolute;
    top: 30px;
    right: 30px;
    font-size: 24px;
  }
}
</style>
